fix: skip priming events and closeSSEStream for old protocol versions #1233
+146
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes backwards compatibility issue where SEP-1699 priming events break old clients.
Motivation and Context
SEP-1699 introduced "priming events" - SSE events with an ID but empty data (
data: \n). Old clients (SDK versions before the empty-data fix) try toJSON.parse("")and crash with "Unexpected end of JSON input".Additionally, the
closeSSEStreamcallbacks should not be provided to old clients because they can't resume if the stream is closed early (they never received a priming event with an event ID).How Has This Been Tested?
closeSSEStreamcallbacks are NOT provided for old protocol versionsBreaking Changes
None. This is a backwards-compatible fix that makes new servers work correctly with old clients.
Types of changes
Checklist
Additional context
The fix gates on protocol version >= 2025-11-25:
params.protocolVersionmcp-protocol-versionheaderString comparison works for ISO date format versions (e.g.,
'2025-03-26' < '2025-11-25'→ true).